package com.example.unittestdemo

import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.unittestdemo.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        bindClick()
    }


    private fun bindClick() {
        binding.btnClick.setOnClickListener { jump2detail(it.context) }
        binding.btnToast.setOnClickListener { showToast(it.context) }
    }

    private fun jump2detail(context: Context) {
        DetailActivity.show(context)
    }

    private fun showToast(context: Context) {
        Toast.makeText(context, "Hello World!", Toast.LENGTH_SHORT).show()
    }


}